<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/manage/common/taglibs.jsp"%>

<script language="JavaScript">
function manage_resource_editform_onSubmit(){
	var form = $('#manage_resource_editform');
	var menuIds = $("input[name='cbmenuid']:checked",form);
	if(menuIds.length != 1){
		$.messager.alert('提示', "请选择所属（一个）菜单");
		return false;
	}
	$("input[name='menuId']",form).val($(menuIds).attr('value'));
	return $(form).form('validate');
}

function manage_resource_onSuccessLoad(){
	var currentMenu = '${resource.menu != null?resource.menu.id:""}';
	var form = $('#manage_resource_editform');
	var menuIds = $("input[name='cbmenuid']", form).each(function(){
		if($(this).val() == currentMenu){
			$(this).attr("checked","true");
		}
	});
}

</script>


<div align="center">
    <form id="manage_resource_editform" action="${pageContext.request.contextPath}/manage/system/resource/${action=='create'?'saveJson':'updateJson'}.html" method="post">
      <jodd:form bean="resource" scope="request">
        <input name="id" type="hidden" />
        <table class="tableForm">
          <tr>
            <th style="width: 80px">资源名称：</th>
            <td><input name="name" type="text" class="easyui-validatebox" data-options="required:true" /></td>
          </tr>
          <tr>
            <th>加载方式：</th>
            <td>
                <select name="showMode" style="width: 150px;" class="easyui-combobox" data-options="required:true">
                   <c:forEach items="${allShowModes}" var="e">
                      <option value="${e.key}">${e.value}</option>
                   </c:forEach>
                </select>
            </td>
          </tr>
          <tr>
            <th>资源类型：</th>
            <td>
                <select name="resType" style="width: 150px;" class="easyui-combobox" data-options="required:true">
                    <option value="URL" ${resource.resType == 'URL'?"selected":""}>URL</option>
                    <option value="FUNCTION" ${resource.resType == 'FUNCTION'?"selected":""}>FUNCTION</option>
                </select>
            </td>
          </tr>          
            <tr>
              <th>资源串：</th>
              <td><input name="resString" type="text" class="easyui-validatebox" data-options="required:true" size="50"/></td>
            </tr>                   
          <tr>
            <th>资源图标：</th>
            <td>
            <c:forEach items="${allIcons}" var="e">
                <span><input type="radio" name="icon" value="${e}" ${resource.icon==e? "checked='checked'":""} /></span>
                <span style='vertical-align:middle;display:inline-block; width:16px; height:16px;' class="${e}"></span>
              </c:forEach>
            </td>
          </tr>
          <tr>
            <th>所属菜单：</th>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td colspan="2">
              <input type="hidden" name="menuId">
              <div align="left">
                  <table id="manage_resource_menu_datagrid" class="easyui-datagrid" 
                  fit="false" border="true" idFeild="cbmenuid"
                  data-options="fitColumns:true,singleSelect:true,onLoadSuccess:manage_resource_onSuccessLoad" checkOnSelect="false" selectOnCheck="false">
                    <thead>
                      <tr>
                        <th data-options="field:'cbmenuid',checkbox:true" width="20%">编号</th>
                        <th data-options="field:'name'" width="30%">菜单名称</th>
                        <th data-options="field:'descn'" width="50%">说明</th>
                      </tr>
                      </thead>
                      <tbody>  
                      <c:forEach items="${menus}" var="e" varStatus="s">
                        <tr>
                          <td>${e.id}</td>
                          <td>${e.name }</td>
                          <td>${e.descn }</td>
                        </tr>                  
                      </c:forEach>
                      </tbody>
                    </table>
              </div>            
            
            </td>
          </tr>
        </table>
      </jodd:form>
    </form>
</div>


